<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link href="css/index2.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
</head>
<body>
<form action="list" method="post">

<input type="button" value="全选"  onclick="quan(this)">
<input type="button" value="全不选"  onclick="buxaun(this)">
<input type="button" value="添加" onclick="add()">
<input type="button" value="删除" onclick="shan()">
	<table>
		<tr>
			<c:forEach items="${pg.list}" var="s">
				<td>
				<img width="200px" src="<%=request.getContextPath() %>/img/${s.tu}">
				<br><input type="button" value="详情" onclick="xiang(${s.id})"> 
				<input type="button" value="商品编辑" onclick="xiu(${s.id})">
				<input type="checkbox" value="${s.id}" class="pp">
				</td>
			</c:forEach>
			<jsp:include page="/jquery/page.jsp"></jsp:include>
		</tr>
	</table>
</form>

<script type="text/javascript">
	function xiang(id) {
		location="selectxiang?id="+id;
	}
	function xiu(id) {
		location="updategood?id="+id;
	}
	function add() {
		location="addgood";
	}
	
	function quan(thiz) {
		$(".pp").attr("checked",true);
	}
	function buxaun(thiz) {
		$(".pp").attr("checked",false);
	}
	function shan() {
		var id=$(".pp:checked").map(function () {
			return $(this).val();
		}).get().join()
		$.post(
			"delete",
			{id:id},
			function (mas) {
				if(mas){
					alert("删除成功");
					location.reload();
				}else{
					alert("删除失败");
				}
			}
		)
	}

</script>


</body>
</html>